import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import "./assets/css/global.css";
import http from "./utils/query";
import filters from "./utils/filters";
import BaiduMap from "vue-baidu-map";
// 导入富文本编辑器
import VueQuill from "vue-quill";

import moment from "moment";
// 重写 console.log 清除调试信息
console.log(process.env)
if (process.env['NODE_ENV'] !== 'development') {
  window.console.log = () => null;
}
import { fileControllerMixins } from "@/mixins/mixins";

Vue.use(BaiduMap, {
  ak: "uWa2q65SQLPAGvCbTlMDRXQ65W8GiVi7",
});

Vue.use(VueQuill);

Vue.use(ElementUI);
Vue.config.productionTip = false;
// 接口统一封装并放置在$http
Vue.prototype.$http = http;
//引入moment
Vue.prototype.$moment = moment;
// 接口统一封装过滤器
for (let key in filters) {
  Vue.filter(key, filters[key]);
}

router.beforeEach(
  (to, from, next) => {
    if (to.name !== "Login" && !sessionStorage.getItem("token")) {
      next({ name: "Login" });
    } else {
      next();
    }

  },
);

new Vue({
  router,
  mixins: [fileControllerMixins],
  render: h => h(App),
}).$mount("#app");
